package com.umfwechat.util;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.umfwechat.common.ReqMessage;
import com.umfwechat.common.constant.CommonConsts;
import com.umpay.operation.util.Constants;




/**
 * @ClassName ReqMessageUtil
 * @desc 组装请求server信息（ReqMessage）的类
 * @author xuhuanchao xuhuanchao@umpay.com
 * @date 2016-10-8上午10:04:22
 * @version 1.0
 */
public class ReqMessageUtil {
	private static Logger logger = LoggerFactory.getLogger(ReqMessageUtil.class);
	/**
	 * @Description	: 组装请求自服务平台server信息（ReqMessage）
	 * @return		：返回req
	 * @author xuhuanchao xuhuanchao@umpay.com
	 * @date 2016-10-8上午10:12:30
	 */
	public static com.umpay.spapply.common.ReqMessage makespaReq(){
		com.umpay.spapply.common.ReqMessage req = new com.umpay.spapply.common.ReqMessage();
		Date nowDate = new Date();
		req.setReqDate(DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatDay8Str));
		req.setReqTime(DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatTime6Str));
		req.setRpid("umfWPlat" + SerialUtil.getRpid(CommonConsts.RPID_SEQ,10));
		return req;
	}
	
	/**
	 * @Description	: 组装请求运营平台server信息（ReqMessage）
	 * @return		：返回req
	 * @author  renjie renjie@umpay.com
	 * @date 2016-10-31上午10:12:30
	 */
	public static com.umpay.operation.common.ReqMessage makeOpReq(){
		com.umpay.operation.common.ReqMessage req=new com.umpay.operation.common.ReqMessage();
		Date nowDate = new Date();
		req.setReqDate(DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatDay8Str));
		req.setReqTime(DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatTime6Str));
		req.setRpid("saasPlat" + SerialUtil.getRpid(Constants.RPID_SEQ,10));
		return req;
		
	}
	
	/**
	 * @Description	: 组装请求运营平台server信息（ReqMessage）
	 * @return		：返回req
	 * @author  renjie renjie@umpay.com
	 * @date 2016-10-31上午10:12:30
	 */
	public static com.umpay.sp.model.common.ReqMessage makeSpReq(){
		com.umpay.sp.model.common.ReqMessage req=new com.umpay.sp.model.common.ReqMessage();
		Date nowDate = new Date();
		req.setReqDate(DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatDay8Str));
		req.setReqTime(DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatTime6Str));
		req.setRpid("saasPlat" + SerialUtil.getRpid(CommonConsts.RPID_SEQ,10));
		return req;
		
	}
	/**
	 * @Description	: 企业版req转换为自服务req（ReqMessage）
	 * @return		：返回req
	 * @author  wangliang wangliang@umpay.com
	 * @date 2016-10-31上午10:12:30
	 */
//	public static com.umpay.spapply.common.ReqMessage spTospaReq(ReqMessage req){
//		com.umpay.spapply.common.ReqMessage reqSpa = new com.umpay.spapply.common.ReqMessage();
//		reqSpa.setRpid(StringUtil.trim(req.getRpid()));
//		reqSpa.setReqDate(StringUtil.trim(req.getReqDate()));
//		reqSpa.setReqTime(StringUtil.trim(req.getReqTime()));
//		Map<String,Object> spaMap = new HashMap<String, Object>();
//		Map<String,String> spMap = req.getReqMap();
//		Iterator<Entry<String,String>> it = spMap.entrySet().iterator();
//		while (it.hasNext()) {
//			Entry<String,String> en = it.next();
//			spaMap.put(en.getKey(), en.getValue());
//		}
//		reqSpa.setReqMap(spaMap);
//		return reqSpa;
//	}
	/**
	 * @Description	:自服务req转换为企业版req（ReqMessage）
	 * @return		：返回req
	 * @author  wangliang wangliang@umpay.com
	 * @date 2016-10-31上午10:12:30
	 */
//	public static ReqMessage spaTospReq(com.umpay.spapply.common.ReqMessage req){
//		ReqMessage reqSp = new ReqMessage();
//		reqSp.setRpid(StringUtil.trim(req.getRpid()));
//		reqSp.setReqDate(StringUtil.trim(req.getReqDate()));
//		reqSp.setReqTime(StringUtil.trim(req.getReqTime()));
//		Map<String,Object> spaMap = req.getReqMap();
//		Map<String,String> spMap = new HashMap<String, String>();
//		Iterator<Entry<String,Object>> it = spaMap.entrySet().iterator();
//		while (it.hasNext()) {
//			Entry<String,Object> en = it.next();
//			spaMap.put(en.getKey(), en.getValue());
//		}
//		reqSp.setReqMap(spMap);
//		return reqSp;
//	}
	/**
	 * @Description	: 组装请求微信前置信息（ReqMessage）
	 * @return		：返回req
	 * @author  renjie renjie@umpay.com
	 * @date 2016-10-31上午10:12:30
	 */
	public static ReqMessage makeReq(){
		ReqMessage req=new ReqMessage();
		Date nowDate = new Date();
		req.setReqDate(DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatDay8Str));
		req.setReqTime(DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatTime6Str));
		req.setRpid("saasPlat" + SerialUtil.getRpid(CommonConsts.RPID_SEQ,10));
		return req;
		
	}
	/**
	 * @Description	: 组装请求头信息Map<String, Object> 
	 * @return		：返回map
	 * @author  llb
	 */
	public static Map<String, Object> makeReqMap(){
		Map<String, Object> reqMap = new HashMap<String, Object>();
		Date nowDate = new Date();
		reqMap.put("rpid", "saasPlat" + SerialUtil.getRpid(CommonConsts.RPID_SEQ,10));
		reqMap.put("reqDate", DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatDay8Str));
		reqMap.put("reqTime", DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatTime6Str));
		return reqMap;
		
	}
	/**
	 * @Description	: 组装请求头信息Map<String, Object> 
	 * @return		：返回map
	 * @author  llb
	 */
	public static Map<String, Object> makeReqCrmMap(){
		Map<String, Object> reqMap = new HashMap<String, Object>();
		Date nowDate = new Date();
		reqMap.put("rpid", "saasPlat" + SerialUtil.getRpid(CommonConsts.RPID_SEQ,10));
		return reqMap;
		
	}
	
	/**
	 * @Description	: 组装请求基金信息（ReqMessage）
	 * @return		：返回req
	 * @author  liuchunyan
	 * @date 2017-09-25下午4:12:30
	 */
	public static ReqMessage makeFundReq(){
		ReqMessage req=new ReqMessage();
		Date nowDate = new Date();
		req.setReqDate(DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatDay8Str));
		req.setReqTime(DateTimesUtil.formatDate(nowDate, DateTimesUtil.formatTime6Str));
		req.setRpid("saasFund" + SerialUtil.getRpid(CommonConsts.RPID_SEQ,8)); //16位
		return req;
		
	}
	
}